class mesh_entry():
	"""Contains the details present in the description file"""
	def __init__(self):
		self.description = ''
		self.entries = []
	
	def parse_record(self, file):
		"""Reads a mesh record from the file pointer given"""
		entered = False
		while True:
			line = file.readline()[:-1]
			if not line:
				return entered
			if line[:3] == 'MS ':
				entries = line.split('=')
				self.description = entries[1].strip()
				entered = True
			elif line[:6] == 'ENTRY ' or line[:12] == 'PRINT ENTRY ':
				entries = line.split('=')
				self.entries.append(entries[1].strip())
				entered = True
	
	def only_clean_entries(self):
		"""Returns only entries which do not have brackets or | etc."""
		good = []
		for entry in self.entries:
			if '|' in entry:
				good.append(entry.split('|')[0])
			elif '(' in entry: #order is important since '(' occurs when '|' occurs
				continue
			else:
				good.append(entry)
		return good
	
